<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML>
<html>
<head>
  <title>后台管理系统</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link href="/resources/css/dpl-min.css" rel="stylesheet" type="text/css" />
  <link href="/resources/css/bui-min.css" rel="stylesheet" type="text/css" />
  <link href="/resources/css/page-min.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">

    <form id="searchForm" class="form-horizontal">
        <div class="row">
            <div class="control-group span8">
                <label class="control-label">昵称：</label>
                <div class="controls">
                    <input type="text" class="control-text" name="nickName">
                </div>
            </div>
            <div class="control-group span8">
                <label class="control-label">账号：</label>
                <div class="controls">
                    <input type="text" class="control-text" name="account">
                </div>
            </div>
            <div class="control-group span8">
                <label class="control-label">姓名：</label>
                <div class="controls">
                    <input type="text" class="control-text" name="userName">
                </div>
            </div>
            <input type="hidden" name="type" id="type" value="Customer"/>
            <%--<div class="control-group span8">
                <label class="control-label">状态：</label>
                <div class="controls" >
                    <select name="status" id="" >
                        <option value="">--全部--</option>
                        <option value="NORMAL">正常</option>
                        <option value="FROZEN">冻结</option>
                    </select>
                </div>
            </div>--%>
            <div class="span3 offset2">
                <button  type="button" id="btnSearch" class="button button-primary">搜索</button>
            </div>
        </div>
    </form>

    <div class="search-grid-container">
        <div id="grid"></div>
    </div>
</div>
<script type="text/javascript" src="/resources/js/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="/resources/js/bui-min.js"></script>
<script type="text/javascript" src="/resources/js/config-min.js"></script>
<script type="text/javascript">
    var store,gridCfg;
  BUI.use(['common/search','common/page','bui/grid','bui/overlay','bui/form'],function (Search,Page,Grid,Overlay,Form) {
    var  columns = [
              {title:'名称',dataIndex:'nickName',width:150},
              {title:'账号',dataIndex:'account',width:80},
            {title:'用户类型',dataIndex:'type',width:80,renderer:function(value,obj){
                if(obj.type=='Gold'){
                    return "金牌代理商";
                }else if(obj.type=='General'){
                    return "全国总代";
                }else if(obj.type=="Partner"){
                    return "区域合伙人";
                }else if(obj.type=='Customer'){
                    return "普通用户";
                }
            }},
              {title:'状态',dataIndex:'status',width:80,renderer:function(value,obj){
                    if(obj.status=='NORMAL'){
                        return "正常";
                    }else if(obj.status=='FROZEN'){
                        return "冻结";
                    }else{
                        return "待审核";
                    }
              }},
             {title:'联系电话',dataIndex:'mobile',width:120},
             {title:'加入时间',dataIndex:'dateStr',width:120},
             {title:'推荐人账号',dataIndex:'recommendId',width:120},
             {title:'下级人数',dataIndex:'subSize',width:80},
            {title:'操作',dataIndex:'operate',width:250,renderer:function(value,obj){
                var editStr =  Search.createLink({ //链接使用 此方式
                    id : 'edit' + obj.id,
                    title : '升级',
                    text : '升级',
                    href : '/member/beforeEdit?enter=1&id='+obj.id
                });
                var updateStr =  Search.createLink({ //链接使用 此方式
                    id : 'update' + obj.id,
                    title : '编辑',
                    text : '编辑',
                    href : '/user/beforeEdit?id='+obj.id
                });

                var statusStr = "";
                if(obj.status=='NORMAL'){
                    statusStr = "&nbsp;&nbsp;<a href=\"javascript:void(0);\" onclick=\"updateStatus('"+obj.id+"','FROZEN')\">冻结</a>&nbsp;&nbsp;";
                }else{
                    statusStr = "&nbsp;&nbsp;<a href=\"javascript:void(0);\" onclick=\"updateStatus('"+obj.id+"','NORMAL')\">启用</a>&nbsp;&nbsp;";
                }

                var nextstr =  Search.createLink({ //链接使用 此方式
                    id : 'update' + obj.id,
                    title : '查看'+obj.nickName+'下级',
                    text : '查看下级',
                    href : '/member/listTeam?id='+obj.id+"&level=0"
                });


                var resetStr = "&nbsp;&nbsp;<a href=\"javascript:void(0);\" onclick=\"resetPwd('"+obj.id+"')\">重置密码</a>";
                return editStr+statusStr+nextstr;
            }}
            ];
            store = Search.createStore('/user/listData');
            gridCfg = Search.createGridCfg(columns,{
                tbar : {
                    items : [
                        {text : '<i class="icon-plus"></i>新增',btnCls : 'button button-small',handler:function(){
                            top.topManager.openPage({id:"user_edit",href:"/user/beforeEdit",title:"新增"});
                        }}
                    ]
                },
              plugins : [BUI.Grid.Plugins.CheckSelection] // 插件形式引入多选表格
            });

  });

</script>
<script type="text/javascript" src="/views/js/list.js"></script>
<script type="text/javascript">
    function resetPwd(id){
        BUI.Message.Confirm("确定重置该用户的密码吗？",function(){
            $.ajax({
                url :"/user/resetPwd?r="+Math.random(),
                type : 'post',
                data : {id:id},
                success : function(data){
                    BUI.Message.Alert(data.msg);
                    if(data.success){ //删除成功
                        top.topManager.reloadPage();
                    }
                }
            });
        },'question');
    }
</script>
</body>
</html>  
